package com.hermes.action.json;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;

import com.hermes.biz.common.model.item.ItemDO;
import com.hermes.biz.common.model.item.ItemUserRelationDO;
import com.hermes.biz.common.model.result.ItemResultDO;
import com.hermes.biz.manager.item.impl.ItemOperateManagerImpl;
import com.hermes.biz.manager.item.impl.UserItemRelationManagerImpl;
import com.hermes.common.action.AsynBaseAction;
import com.hermes.common.util.ParameterParserUtil;

public class AsynGetItemsPersonHome extends AsynBaseAction{
	
	private static final long serialVersionUID = -2733669038890093289L;
	public List<ItemUserRelationDO> itemUserRelationList;
	@Resource
	UserItemRelationManagerImpl userItemModel;
	public List<ItemDO> itemDOList;
	@Resource
	ItemOperateManagerImpl itemOperator;
	public int itemLVcount =0;
	
	@Override
	public String execute() throws Exception {
		itemDOList = new ArrayList<ItemDO>();
		long userId = Long.valueOf(ParameterParserUtil.getParameter("uid"));		
		itemUserRelationList = new ArrayList<ItemUserRelationDO>();
		itemUserRelationList = userItemModel.getUserInterestedItems(userId);
		itemLVcount = itemUserRelationList.size();
		for(ItemUserRelationDO itemUserRela : itemUserRelationList){
			ItemResultDO resultDO = itemOperator.getSingleItemByItemId(itemUserRela.getInterestedItemId());
			if(resultDO!=null){
				itemDOList.add(resultDO.getModule());
				
			}else{
				System.out.println("no result for this item id");
			}			
		}		
		return SUCCESS;
	}

}
